package com.company;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * @date : 2023/2/13 16:16
 */

public class P041_BlockingQueue {

    public static void main(String[] args) throws InterruptedException {
        BlockingQueue<String> queue = new ArrayBlockingQueue<>(11);
        for (int i = 0; i < 11; i++) {
            String s = "s" + i;
            System.out.println("字符串" + s + (queue.offer(s) ? "成功" : "失败"));
        }
//        System.out.println("queue.offer(\"123\") = " + queue.offer("123"));
        for (int i = 0; i < 11; i++) {
            System.out.println("i = " + i + " queue.take() = " + queue.take());
        }

    }

}
